package lab02.text21;

public class Text21 {
    public static void main(String[] args) {
        String result="hellomyworldiamcool";

        int count=0;
        double x,a;

        //统计一个字符串中给定字符出现的频率
        for(int i=0;i<result.length();i++){
            String getStr=result.substring(i,i+1);
            if(getStr.equals("o")){
                count++;
            }
        }

        //计算频率
        a=count;
        x=a/result.length();

        System.out.println("出现的频率为："+x);

    }
}